-
Notifications
You must be signed in to change notification settings - Fork 745
/
RouteExtensions.cs
63 lines (53 loc) · 2.06 KB
/
RouteExtensions.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information
namespace DotNetNuke.Web.Api
{
using System.Web.Http.Routing;
using System.Web.Routing;
public static class RouteExtensions
{
private const string NamespaceKey = "namespaces";
private const string NameKey = "name";
/// <summary>Get the name of the route.</summary>
/// <returns>Route name.</returns>
public static string GetName(this Route route)
{
return (string)route.DataTokens[NameKey];
}
/// <summary>Get the name of the route.</summary>
/// <returns>Route name.</returns>
public static string GetName(this IHttpRoute route)
{
return (string)route.DataTokens[NameKey];
}
internal static void SetNameSpaces(this Route route, string[] namespaces)
{
route.DataTokens[NamespaceKey] = namespaces;
}
internal static void SetNameSpaces(this IHttpRoute route, string[] namespaces)
{
route.DataTokens[NamespaceKey] = namespaces;
}
/// <summary>Get Namespaces that are searched for controllers for this route.</summary>
/// <returns>Namespaces.</returns>
internal static string[] GetNameSpaces(this Route route)
{
return (string[])route.DataTokens[NamespaceKey];
}
/// <summary>Get Namespaces that are searched for controllers for this route.</summary>
/// <returns>Namespaces.</returns>
internal static string[] GetNameSpaces(this IHttpRoute route)
{
return (string[])route.DataTokens[NamespaceKey];
}
internal static void SetName(this Route route, string name)
{
route.DataTokens[NameKey] = name;
}
internal static void SetName(this IHttpRoute route, string name)
{
route.DataTokens[NameKey] = name;
}
}
}